import Vue from 'vue'
import moment from 'moment'

/**
 * 格式化日期
 */
Vue.prototype.formatDate = function (date, format) {
    if (format) {
        return moment(date).format(format);
    } else {
        return moment(date).format("YYYY-MM-DD HH:mm:ss");
    }
}

/**
 * 获取地址栏的参数信息
 * @param param
 * @param url
 */
Vue.prototype.getParam = function (param,url) {
    if (!url){
        url = window.location.href;
    }
    return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [, ""])[1].replace(/\+/g, '%20')) || null
}
